//
//  HomeTitleButtonView.swift
//  Weibo
//
//  Created by gdarkness on 16/3/26.
//  Copyright © 2016年 gdarkness. All rights reserved.
//

import UIKit

class HomeTitleButtonView: UIButton {
    
    //便利构造函数，调用当前类的便利构造函数
    convenience init(title: String, imageName: String) {
        self.init()
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        sizeToFit()
        
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        //调整图片位置
        //将label移动到最左边
        titleLabel?.frame.origin.x  = 0
        
        //图片移动label后面
        imageView?.frame.origin.x = titleLabel!.frame.width + 3
    }
}
